<?php

namespace App\Models\Home;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    //
    protected $table='article_category';

    /**
     *
     * 获取当前分类以及其下的所有子分类的Id(二级)
     */
    public function getCateId($cid)
    {
        $cate_id = $this->where('pid',(int)$cid)->get();
        $array = array();
        if($cate_id){
            foreach($cate_id as $value){
                $array[] = $value->id;
            }
        }
        $array[] = (int)$cid;
        return $array;
    }
}
